<?php
	$validation_rules = array(
		"path" => array(
			"required" => true,
            #'path' => true,
            'maxlength' => 255
		),
		"title_en" => array(
            'maxlength' => 255
		),
		"title" => array(
            'maxlength' => 255
		),
        'cpl_id' => array(
            "required" => true,
            'maxlength' => 255
        ),
        'effective_date' => array(
            "required" => true,
            'maxlength' => 255
        )
	);
	$company_code_list = isset($data['company_code_list']) ? $data['company_code_list'] : array();
	$cpl_company_code  = isset($data['cpl_company_code']) ? $data['cpl_company_code'] : 'TVB';
	$cpl_id            = isset($data['cpl_id']) ? $data['cpl_id'] : '';
	$path              = isset($data['path']) ? $data['path'] : '';
	$title		       = isset($data['title']) ? $data['title'] : '';
	$title_en          = isset($data['title_en']) ? $data['title_en'] : '';
	$effective_date    = isset($data['effective_date']) ? $data['effective_date'] : date("Y-m-d");
	$cpl_category_id   = isset($data['cpl_category_id']) ? $data['cpl_category_id'] : '';
?>

<div id="programme-step1" class="mod ui-widget-content ui-helper-clearfix ui-corner-all">
    <div class="hd ui-widget-header ui-helper-clearfix ui-corner-all"><h2><?php echo $act_text; ?> Programme</h2></div>
    <div class="bd">
		<?php FormHelper::StartForm('ane', AC::PDES_BASE_URL.'programme_step1.html?act=add&type=programme&step=2') ?>
            <?php FormHelper::ErrorMessages($errors) ?>
        	<fieldset class="ui-widget-content">
        		<legend class="ui-widget-header">Programme Key</legend>
           	    <?php 
					FormHelper::DropDownList('cpl_company_code', 
											 array('Please select...')+$company_code_list, 
											 $cpl_company_code, 'Company Name');
					FormHelper::TextField('cpl_id', $cpl_id,
										  'Programme No.', false, 'ruler input_status', 1);
				?>
           	    <div class="form-item">
                    <span class="grid-l"><label for="effective_date"><ins title="mandatory field">*</ins>Effective Date (YYYY-MM-DD):</label></span>
                    <span class="grid-r">
                        <input type="text" name="effective_date" id="effective_date" class="datepicker" value="<?php echo $effective_date;?>" autocomplete="off" />
                    </span>
                </div>
        		<?php 
					FormHelper::TextField('path', $path, 
										  'Programme Path', false, 'ruler input_status', 1);
					FormHelper::TextField('title', $title,
										  'Programme Title (Chinese)', false, 'ruler input_status', 2);
					FormHelper::TextField('title_en', $title_en,
										  'Programme Title (English)', false, 'ruler input_status', 2);
				?>
	<input id="cpl_category_id" name="cpl_category_id" type="hidden" value="<?php echo $cpl_category_id;?>" />
        	</fieldset>

            <span class="buttons">
    		    <?php FormHelper::SubmitButton('submit', 'Create') ?>
            </span>
    	<?php FormHelper::EndForm() ?>
    </div>
</div>

<script>
    TVB.Pdes.oValidation = {
        form: document.forms['ane'],
        rules: <?php echo json_encode($validation_rules); ?>
    };
</script>
